export default {
  menuId: "mobile-context-menu",
  getMenus() {
    return [
      {
        title: "编辑",
        key: "edit",
        action: ({ editor, node }) => {
          editor.setSelection([node]);
          if (editor.showPropertyEditor) {
            editor.showPropertyEditor();
          }
        },
      },
      {
        title: "删除",
        key: "delete",
        action: ({ editor, node }) => {
          if (editor && node) {
            editor.removeNode(node.key);
          }
        },
      },
      {
        title: "上移一级",
        key: "up",
        action: ({ editor, node }) => {
          if (editor && node) {
            const { document } = editor.value;
            const lastPath = document.getLastPath(node.key);
            editor.moveNodeByPath(node.key, lastPath);
          }
        },
      },
      {
        title: "下移一级",
        key: "down",
        action: ({ editor, node }) => {
          if (editor && node) {
            const { document } = editor.value;
            const nextPath = document.getNextPath(node.key);
            editor.moveNodeByPath(node.key, nextPath);
          }
        },
      },
    ];
  },
};
